package com.stylefeng.guns.core.common;

import com.stylefeng.guns.core.base.warpper.BaseControllerWarpper;
import com.stylefeng.guns.core.common.constant.factory.ConstantFactory;
import com.stylefeng.guns.modular.revenue.model.Revenue;
import com.stylefeng.guns.modular.system.model.*;

import java.util.List;
import java.util.Map;


public class BaseModelWarpper extends BaseControllerWarpper {
    private  Object index=null;
    public BaseModelWarpper(List<?> list,Object index) {
        super(list);
        this.index=index;
    }

    /**
     * 基于sys_dict表 类型匹配
     * @param map
     */
    @Override
    public void warpTheMap(Map<String, Object> map) {
        //借入借出归还类型
        if(index.equals(BorrowingInfo.class)){
            map.put("typeName", ConstantFactory.me().getDictsByCode("borrowingInfo_type",(Integer)  map.get("type")));
        }
        //收支归类
        if(index.equals(Details.class)){
            map.put("typeName", ConstantFactory.me().getDictsByCode("Details_type",(Integer)  map.get("type")));
        }
        if(index.equals(Expenditure.class)){
            map.put("platformName", ConstantFactory.me().getDeptNameByCode( map.get("platform").toString()));
        }
        if(index.equals(BorrowingInfo.class)){
            map.put("platformName", ConstantFactory.me().getDeptNameByCode( map.get("platform").toString()));
            map.put("contactName", ConstantFactory.me().getCustomerName( map.get("contact").toString(),map.get("platform").toString()));
        }
        if(index.equals(CashExpenditure.class)){
            map.put("platformName", ConstantFactory.me().getDeptNameByCode( map.get("platform").toString()));
            map.put("moneyTypeName", ConstantFactory.me().getDictsByCode("CE_moneyType",(Integer)  map.get("moneyType")));
            map.put("typeName", ConstantFactory.me().getDictsByCode("CE_type",(Integer)  map.get("type")));
            map.put("detailsName", ConstantFactory.me().getDetailsName((Integer)  map.get("detailsId")));
            map.put("customerName", ConstantFactory.me().getCustomerName( map.get("customer").toString(),map.get("platform").toString()));

        }
        if(index.equals(Bank.class)){
            map.put("banktypeName", ConstantFactory.me().getDictsByCode("bank_type",(Integer)  map.get("banktype")));
            map.put("statusName", ConstantFactory.me().getDictsByCode("bank_status",(Integer)  map.get("status")));
            map.put("platformName", ConstantFactory.me().getDeptNameByCode( map.get("platform").toString()));
        }
        if(index.equals(Revenue.class)){
            map.put("platformName", ConstantFactory.me().getDeptNameByCode( map.get("platform").toString()));
        }
        if(index.equals(Payroll.class)){
            map.put("platformName", ConstantFactory.me().getDeptNameByCode( map.get("platform").toString()));
        }
        if(index.equals(RmbCashReceipts.class)){
            map.put("summaryName", ConstantFactory.me().getDetailsName((Integer)  map.get("summary")));
            map.put("typeName", ConstantFactory.me().getDictsByCode("CE_type",(Integer)  map.get("type")));
            map.put("customerName", ConstantFactory.me().getCustomerName( map.get("customer").toString(),map.get("platform").toString()));
        }





    }

}
